/*
Copyright 2011 Johan Maasing

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package nu.zoom.catonine.prefs.gui.impl;

import javax.swing.JCheckBoxMenuItem;

import nu.zoom.catonine.prefs.gui.PreferencesGUI;
import nu.zoom.swing.desktop.WorkbenchFrame;
import nu.zoom.swing.desktop.common.action.ToggleFrameAction;
import nu.zoom.ui.Resources;
import nu.zoom.ui.Resources.ResourceNotFoundException;

/**
 * @author "Johan Maasing" &lt;johan@zoom.nu&gt;
 * 
 */
public class OpenPreferencesAction extends ToggleFrameAction<JCheckBoxMenuItem> {
	private static final long serialVersionUID = 6450439901369128716L;
	private final PreferencesGUI preferencesGUI;

	public OpenPreferencesAction(final PreferencesGUI preferencesGUI, final Resources resources)
			throws ResourceNotFoundException {
		super(new JCheckBoxMenuItem());
		this.preferencesGUI = preferencesGUI;
		setName(resources.getMessage("nu.zoom.catonine.preferences.menu"));
		setToolTip(resources.getMessage("nu.zoom.catonine.preferences.menu.tt"));
		setIcon(resources.getIcon("nu.zoom.catonine.preferences.menu.icon"));
	}

	@Override
	public void frameDetached(WorkbenchFrame frame) {
	}

	@Override
	public void frameAttached(WorkbenchFrame frame) {
	}

	@Override
	protected WorkbenchFrame createFrame() {
		return preferencesGUI.displayPreferences();
	}
}
